{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5895d96a-ca61-4811-a1a3-897eea490164",
   "metadata": {},
   "outputs": [],
   "source": [
    "str = 'apple\\n'\n",
    "print(str)\n",
    "s_list = list(str)\n",
    "print(s_list)\n",
    "s_list.pop(0)\n",
    "print(1, s_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "835c3eb3-c73c-4604-b6b5-41450d8fd423",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "N = 15\n",
    "# 新建3组点(x,y)，每组15个，x,y大小在区间[0,100]之间\n",
    "X1 = np.random.rand(N) * 100\n",
    "print(X1)\n",
    "Y1 = np.random.rand(N) * 100\n",
    "X2 = np.random.rand(N) * 100\n",
    "Y2 = np.random.rand(N) * 100\n",
    "X3 = np.random.rand(N) * 100\n",
    "Y3 = np.random.rand(N) * 100\n",
    "plt.scatter(X1, Y1, c='r', s=100, alpha=0.5)  # c颜色，s大小，alpha透明度\n",
    "plt.scatter(X2, Y2, c='g', s=200, alpha=0.5)\n",
    "plt.scatter(X3, Y3, c='b', s=300, alpha=0.5)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a5de2892-119c-499d-a3e3-e712bb17767a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the first element now： ['a', 'b', 'c', 'd']\n",
      "1 the first element after modifed： ['e', 'b', 'c', 'd']\n",
      "2 ('abcd', 'erye', 456, 789, 123)\n",
      "3 abcd\n",
      "4 (456, 789, 123)\n",
      "tuple before ('abcd', 'erye', 456, 789, 123)\n",
      "tuple after ('abcd', 'erye', 456, 789, 123)\n",
      "list before ['abcd', 'erye', 456, 789, 123]\n",
      "list after [[243, 215, 23, 5, 235, 325], 'erye', 456, 789, 123]\n",
      "我爱小杨 abcd erye 456 789 123\n",
      "[ 1  2 34  4  5]\n",
      "['e' 'b' 'c' 'd']\n"
     ]
    }
   ],
   "source": [
    "#修改\n",
    "nameList=['a','b','c','d']\n",
    "print('the first element now：',nameList)\n",
    "nameList[0]='e'\n",
    "print(1,'the first element after modifed：',nameList)\n",
    "#元组\n",
    "tuple = ('abcd','erye',456,789,123)\n",
    "list = ['abcd','erye',456,789,123]\n",
    "num = 2\n",
    "print(2,tuple)\n",
    "print(3,tuple[0])\n",
    "print(4,tuple[2:])\n",
    "print(\"tuple before\", tuple)\n",
    "#tuple[0] = [243,215,23,5,235,325]\n",
    "print(\"tuple after\", tuple)\n",
    "print(\"list before\", list)\n",
    "list[0] = [243,215,23,5,235,325]\n",
    "print(\"list after\", list)\n",
    "a,b,c,d,e = tuple\n",
    "print(\"我爱小杨\", a,b,c,d,e)\n",
    "# list 操作\n",
    "# .remove\n",
    "# .append\n",
    "# .pop\n",
    "# .replace\n",
    "import numpy as np\n",
    "arr = np.array([1,2,34,4,5])\n",
    "print(arr)\n",
    "arr = np.array(nameList)\n",
    "print(arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a16c3b9a-29d9-457b-9ef1-8347745d6a3c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "[[243, 215, 23, 5, 235, 325], 'erye', 456, 789, 123]\n",
      "sss\n",
      "0 {'ali', 't', 'g', 'F'} <class 'set'>\n",
      "1 {'g', 'apple', 'ali', 'F', 't'} <class 'set'>\n",
      "2 {'ali', 't', 'F'}\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "#需要注意的两个元组\n",
    "tup = () #空元组\n",
    "tup = (1,22,44,444)\n",
    "tup = (1)\n",
    "print(tup)\n",
    "li = [1,2]\n",
    "print(list)\n",
    "print(\"sss\")\n",
    "# insert function\n",
    "gafataSets={'t','ali','g','F'}\n",
    "print(0,gafataSets,type(gafataSets))\n",
    "gafataSets.update(['apple'])\n",
    "print(1,gafataSets,type(gafataSets))\n",
    "\n",
    "# delete function\n",
    "gafataSets={'t','ali','g','F'}\n",
    "gafataSets.discard('g')\n",
    "print(2,gafataSets)\n",
    "# search\n",
    "txBool = 't' in gafataSets\n",
    "print(txBool)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "290c4a1f-8f70-4ab0-a412-d0a1001fb933",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'002': '马云', '003': '王健林', '004': '马化腾'}\n",
      "0 {}\n",
      "1 {'001': ['猴子', 29, '1型糖尿病', '较差'], '002': ['马云', 30, '2型糖尿病', '好转'], '003': ['王健林', 31, '3型糖尿病', '显著好转'], '004': ['马化腾', 32, '4型糖尿病', '可以出院']}\n",
      "2 {'001': ['猴子', 29, '1型糖尿病', '较差'], '002': ['马云', 30, '2型糖尿病', '好转'], '003': ['王健林', 31, '3型糖尿病', '显著好转'], '004': ['马化腾', 32, '4型糖尿病', '可以出院'], '005': ['王思聪', 30, '1型糖尿病', '好转']}\n",
      "2.1 {'001': ['猴子', 29, '1型糖尿病', '较差'], '002': ['马云', 30, '2型糖尿病', '好转'], '003': ['王健林', 31, '3型糖尿病', '显著好转'], '004': ['马化腾', 32, '4型糖尿病', '可以出院']}\n",
      "3 ['猴子', 29, '1型糖尿病', '较差']\n",
      "4 修改之前： ['猴子', 29, '1型糖尿病', '较差']\n",
      "5 修改之后： ['猴子', 29, '1型糖尿病', '好转']\n"
     ]
    }
   ],
   "source": [
    "#映射\n",
    "patientDic = {'001':'猴子','002':'马云','003':'王健林','004':'马化腾'}\n",
    "# delete key:value\n",
    "patientDic.pop('001')\n",
    "print(patientDic)\n",
    "# clear all elements\n",
    "patientDic.clear()\n",
    "print(0,patientDic)\n",
    "#定义字典，病人存储\n",
    "patientDic2={'001':['猴子',29,'1型糖尿病','较差'],\n",
    "             '002':['马云',30,'2型糖尿病','好转'],\n",
    "             '003':['王健林',31,'3型糖尿病','显著好转'],\n",
    "             '004':['马化腾',32,'4型糖尿病','可以出院']}\n",
    "print(1,patientDic2)\n",
    "#insert\n",
    "patientDic2['005']=['王思聪',30,'1型糖尿病','好转']\n",
    "print(2,patientDic2)\n",
    "#删除\n",
    "del patientDic2['005']\n",
    "print(2.1,patientDic2)\n",
    "#patientDic2.pop('005')\n",
    "\n",
    "#查询\n",
    "valueList=patientDic2['001']\n",
    "print(3,valueList)\n",
    "#修改\n",
    "print(4,'修改之前：',patientDic2['001'])\n",
    "patientDic2['001']=['猴子',29,'1型糖尿病','好转']\n",
    "print(5,'修改之后：',patientDic2['001'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "65494618-9981-4941-9d2e-502ef51878c0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
